<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div class="r_location">
	<i class="r_txtico"></i> 用户信息管理 &gt; 贴士发送管理 &gt; 修改贴士
</div>
<form id="qForm" action="tips/update" method="post">
	<ul class="all_list">
		
		<li>
			<span class="all_title">通知对象：</span>
			<span>
				<input type="text" class="ui_input" id="roleList" validator='{"label":"通知对象","isOnBlurEnable":false}' readonly="readonly" name="roleList2" style="width: 400px;" value="${roleNameList }" />
			</span>
			<span>
				<input type="button" value="选择" id="select_role" class="btn_blue m-r15" />
			</span>
		</li>
		<li>
			<span class="all_title">显示日期：</span>
			<span>
				<input type="text" class="ui_input Wdate" id="displayDateFrom" readonly="readonly" name="displayDateFrom" validator='{"label":"显示日期","groupId":"displayDate","isRequiredStyleInUse":false}' onclick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'%y-%M-%d',maxDate:'#F{$dp.$D(\'displayDateTo\')}'})" value="<fmt:formatDate value="${tips.displayDateFrom}" pattern="yyyy-MM-dd" />" /> -
				<input type="text" class="ui_input Wdate" id="displayDateTo" readonly="readonly" name="displayDateTo" validator='{"label":"显示日期","groupId":"displayDate"}' onclick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'displayDateFrom\')}'})" value="<fmt:formatDate value="${tips.displayDateTo}" pattern="yyyy-MM-dd" />" />
			</span>
		</li>
		<li>
			<span class="all_title">显示时间：</span>
			<span>
				<input maxlength="3" type="text" class="ui_input" id="displayTime" validator='{"label":"显示时间","isNZADigit":true,"customFun":"validateDisplayTime","suffixTxt":"(秒)不得超过120秒"}' name="displayTime" value="${tips.displayTime }" />
			</span>
		</li>
		<li>
			<span class="all_title">显示次数：</span>
			<span>
				<input type="text" class="ui_input " id="displayCount" validator='{"label":"显示次数","isNZADigit":true,"suffixTxt":"显示次数:每天登录显示的次数,如3次,则3次登录,则显示,第4次登录则不显示"}' name="displayCount"  value="${tips.displayCount }"/>
			</span>
		</li>
		<li class="m-t10">
			<span class="all_title">贴士内容：</span>
			<span>
				<textarea validator='{"label":"贴士内容"}' class="ui_input " id="content" style="width:500px;height:300px" name="content">${tips.content }</textarea>
			</span>
		</li>
		<li>
			<span class="all_title"></span>
			<span>
				<input type="button" id="query" value="修改" class="btn_blue m-r15 submitBtn" />
				<input type="button" value="返回" class="reset_btn m-r15" id="back_button" />
				<input type="hidden" id="roleListId" name="roleListId" value="${roleIdList }" />
				<input type="hidden" id="tipsId" name="id" value="${tips.id }" />
			</span>
		</li>
	</ul>
</form>
<script>
	$(function() {
		// 选择角色弹出框
		$("#select_role, #roleList").click(function(){
			showDialog('tips/role', {
				width : '600px',
				title : '选择角色',
				lock : true,
				param : {
					roleListId : $("#roleListId").val()
				}
			});
		});
		function showDialog(url, options) {
			myDialog = art.dialog(options);// 初始化一个带有loading图标的空对话框
			$.post(url, options.param, function(data) {
				myDialog.content(data);
			});
		}
		// 后退按钮
		$("#back_button").click(function(){
			to_page('/tips/view/page');
		});
		// 修改表单提交
		$("#qForm").validator({}, {
			callback : function(results){
				art.dialog({
					title : '修改贴士',
					lock : true,
					content : '确认修改贴士?',
					width : '200px',
				    cancelVal: '关闭',
				    cancel: true,
					ok : function () {
						$("#qForm").ajaxSubmit(function(data){
							if(data.success==='succeed'){
								to_page('/tips/view/page');
							}else{
								art.dialog({icon: data.success,content: data.message,lock:true});
							}
						});
					}
				});
			}
		});
	});
	// 自定义校验显示时间
	function validateDisplayTime() {
		var result = {};
		result.result = true;
		var num = Number($('#displayTime').val());
		if (num > 120) {
			result.result = false;
			result.msg = "显示时间不得超过120秒";
		}
		
		return result;	
	}
</script>